#ifndef value_compil_h
#define value_compil_h


#include <string>
#include "Type.hpp"
#include "3adCode.hpp"

class Value {
	private:
	union{
		int i;
		double d;
		char c;
		bool b;
		std::string * s;
	} theValue;

	char theType;

	public:
	Value(int i);
	Value(double d);
	Value(char c);
	Value(bool b);
	Value(std::string * s);
	Value();
	virtual ~Value();

	bool isOfType(Type * type);

	bool isChar();
	bool isString();
	bool isInteger();
	bool isReal();
	bool isIntervalLimit();
	bool isNumeric();
	bool isBoolean();
	
	int getInteger();
	double getReal();
	char getChar();
	bool getBoolean();
	std::string getString();

	char getValType();
	Value * clone();


	virtual void show();
	static Value* calculate(CodeInstruction unaryOperator, Value* value1);
	static Value* calculate(CodeInstruction binaryOperator, Value* value1, Value* value2);
};

class NilValue : public Value {
	public:
		NilValue() {}
		~NilValue() {}
		void show() {
			std::cout << "nil";
		}
};

#endif
